﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Text;

namespace BlueLotus7.Eden.Web
{
    public class BaseController : Controller
    {
        #region Column Styles

        protected const string Column_DomainScopeUserName = "col-domain-user-name";
        protected const string Column_DomainScopeName = "col-domain-scope-name";
        protected const string Column_Stamp = "col-stamp";
        protected const string Column_Name = "col-name";
        protected const string Column_Status = "col-status";

        #endregion


        public JavaScriptResult RetrieveAjaxCollection()
        {
            string controllerName = this.RouteData.Values["controller"].ToString();
            StringBuilder text = new StringBuilder();
            text.Append(@"var ajaxCollection = bluelotus7.ajaxCollection = new Object();");

            foreach (string action in AjaxCollection.Instance.GetAjaxCollectionByControllerName(controllerName))
            {
                text.Append(string.Format("ajaxCollection['{0}'] = '{1}';", action, Url.Action(action)));
            }

            return JavaScript(text.ToString());
        }
    }
}
